eager_load と preload の使い分け
`eager_load`https://devdocs.io/rails~8.0/activerecord/querymethods#method-i-eager_loadhttps://railsguides.jp/active_record_querying.html#eager-load`LEFT OUTER JOIN` で関連先も一気に取得する[warning.icon] データが巨大になると逆に [パフォーマンス] が劣化する
const users = await getUsers()
for (const user of users) {
const posts = await getPostsByUserId(user.id)
// ...
}
JOIN
の活用const users = await getUsers()
const userIds = users.map((user) => user.id)
const posts = await getPostsByUserIds(userIds)